{extend name="common:base" /}

{block name="title"}Upload API Document - {$config.site_name}{/block}

{block name="main"}
<style>
  tbody tr:last-child td {
      border-bottom: none;
  }
  .mdui-table td {
      line-height: 36px;
  }
  .mdui-shadow-2 {
      box-shadow: 0 0 10px 0 rgba(45, 45, 45, 0.13);
  }
</style>
<div class="mdui-container">
  <main>
    <div class="mdui-m-b-2">
      <h2>1. 获取Token</h2>
      <div class="mdui-row">
        <div class="mdui-col-md-6">
          <div class="mdui-table-fluid mdui-m-t-1">
            <table class="mdui-table">
              <thead>
              <tr>
                <td>功能</td>
                <td>接口</td>
              </tr>
              </thead>
              <tbody>
              <tr>
                <td>请求方式</td>
                <td>POST</td>
              </tr>
              <tr>
                <td>URL</td>
                <td>{$domain}/api/token</td>
              </tr>
              </tbody>
            </table>
          </div>
        </div>
      </div>
      <h4 class="mdui-m-t-2 mdui-m-b-1">请求参数</h4>
      <div class="mdui-table-fluid">
        <table class="mdui-table">
          <thead>
          <tr>
            <td>参数名称</td>
            <td>类型</td>
            <td>是否必须</td>
            <td>说明</td>
          </tr>
          </thead>
          <tbody>
          <tr>
            <td>email</td>
            <td>String</td>
            <td>是</td>
            <td>邮箱</td>
          </tr>
          <tr>
            <td>password</td>
            <td>String</td>
            <td>是</td>
            <td>账号密码</td>
          </tr>
          </tbody>
        </table>
      </div>
      <h4 class="mdui-m-t-2 mdui-m-b-1">返回数据说明</h4>
      <div class="mdui-table-fluid">
        <table class="mdui-table">
          <thead>
          <tr>
            <td>参数名称</td>
            <td>类型</td>
            <td>实例值</td>
            <td>说明</td>
          </tr>
          </thead>
          <tbody>
          <tr>
            <td>code</td>
            <td>Number</td>
            <td>200</td>
            <td>状态码，成功返回200，失败返回500</td>
          </tr>
          <tr>
            <td>msg</td>
            <td>String</td>
            <td>success</td>
            <td>提示信息</td>
          </tr>
          <tr>
            <td>time</td>
            <td>Number</td>
            <td>1544176295</td>
            <td>响应时间戳</td>
          </tr>
          <tr>
            <td>data</td>
            <td>array|object</td>
            <td>{"token": "8961576c9090ef0902c4b89406f8d557"}</td>
            <td>获取的token数据</td>
          </tr>
          </tbody>
        </table>
      </div>
    </div>

    <div class="mdui-m-b-2">
      <h2>2. 图片上传</h2>
      <div class="mdui-row">
        <div class="mdui-col-md-6">
          <div class="mdui-table-fluid mdui-m-t-1">
            <table class="mdui-table">
              <thead>
              <tr>
                <td>功能</td>
                <td>接口</td>
              </tr>
              </thead>
              <tbody>
              <tr>
                <td>请求方式</td>
                <td>POST</td>
              </tr>
              <tr>
                <td>URL</td>
                <td>{$domain}/api/upload</td>
              </tr>
              </tbody>
            </table>
          </div>
        </div>
      </div>
      <h4 class="mdui-m-t-2 mdui-m-b-1">请求参数</h4>
      <div class="mdui-table-fluid">
        <table class="mdui-table">
          <thead>
          <tr>
            <td>参数名称</td>
            <td>类型</td>
            <td>是否必须</td>
            <td>说明</td>
          </tr>
          </thead>
          <tbody>
          <tr>
            <td>image</td>
            <td>File</td>
            <td>是</td>
            <td>表单名称</td>
          </tr>
          </tbody>
        </table>
      </div>
      <div class="mdui-shadow-2 mdui-m-t-2 mdui-m-b-1 mdui-p-a-3 mdui-text-color-red">
        注意：请求时header如果有参数 token，接口则认证该token，上传的图片也是在该token用户下，否则为游客上传。
      </div>
      <h4 class="mdui-m-t-2 mdui-m-b-1">返回数据说明</h4>
      <div class="mdui-table-fluid">
        <table class="mdui-table">
          <thead>
          <tr>
            <td>参数名称</td>
            <td>类型</td>
            <td>实例值</td>
            <td>说明</td>
          </tr>
          </thead>
          <tbody>
          <tr>
            <td>code</td>
            <td>Number</td>
            <td>200</td>
            <td>状态码，成功返回200，失败返回500</td>
          </tr>
          <tr>
            <td>msg</td>
            <td>String</td>
            <td>success</td>
            <td>提示信息</td>
          </tr>
          <tr>
            <td>time</td>
            <td>Number</td>
            <td>1544176295</td>
            <td>响应时间戳</td>
          </tr>
          <tr>
            <td>data</td>
            <td>array|object</td>
            <td>
<pre>{
  "name": "9B7BCFBD05891B2D42187F126887777A.jpg",
  "url": "http://域名/2018/12/08/5c0b519f44701.jpg"
}</pre>
            </td>
            <td>图片数据</td>
          </tr>
          </tbody>
        </table>
      </div>
      <h4 class="mdui-m-t-2 mdui-m-b-1">上传示例</h4>
      <pre class="mdui-shadow-2 mdui-p-a-3">
POST /api/upload HTTP/1.1
Host: {$domain}

Connection: keep-alive
Content-Length: 57398
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryx2mqINKHVPJ8yMdK

------WebKitFormBoundaryx2mqINKHVPJ8yMdK
Content-Disposition: form-data; name="image"; filename="test.png"
Content-Type: image/png
</pre>
      <h4 class="mdui-m-t-2 mdui-m-b-1">响应错误示例</h4>
      <pre class="mdui-shadow-2 mdui-p-a-3">
{
  "code": 500,
  "msg": "管理员关闭了游客上传！",
  "data": null,
  "time": 1544245931
}</pre>
    </div>

    <div class="mdui-shadow-2 mdui-m-t-2 mdui-m-b-1 mdui-p-a-3 mdui-text-color-red">
      注意：以下接口均需要 Token
    </div>
    <div class="mdui-m-b-2">
      <h2>3. 获取图片列表</h2>
      <div class="mdui-row">
        <div class="mdui-col-md-6">
          <div class="mdui-table-fluid mdui-m-t-1">
            <table class="mdui-table">
              <thead>
              <tr>
                <td>功能</td>
                <td>接口</td>
              </tr>
              </thead>
              <tbody>
              <tr>
                <td>请求方式</td>
                <td>POST</td>
              </tr>
              <tr>
                <td>URL</td>
                <td>{$domain}/api/images</td>
              </tr>
              </tbody>
            </table>
          </div>
        </div>
      </div>
      <h4 class="mdui-m-t-2 mdui-m-b-1">请求参数</h4>
      <div class="mdui-table-fluid">
        <table class="mdui-table">
          <thead>
          <tr>
            <td>参数名称</td>
            <td>类型</td>
            <td>是否必须</td>
            <td>说明</td>
          </tr>
          </thead>
          <tbody>
          <tr>
            <td>page</td>
            <td>String</td>
            <td>是</td>
            <td>页码</td>
          </tr>
          <tr>
            <td>rows</td>
            <td>String</td>
            <td>否</td>
            <td>每页数量, 默认 20 条</td>
          </tr>
          </tbody>
        </table>
      </div>
      <h4 class="mdui-m-t-2 mdui-m-b-1">返回数据(data)说明</h4>
      <div class="mdui-table-fluid">
        <table class="mdui-table">
          <thead>
          <tr>
            <td>参数名称</td>
            <td>类型</td>
            <td>实例值</td>
            <td>说明</td>
          </tr>
          </thead>
          <tbody>
          <tr>
            <td>total</td>
            <td>Number</td>
            <td>999</td>
            <td>数据总量</td>
          </tr>
          <tr>
            <td>per_page</td>
            <td>String</td>
            <td>1</td>
            <td>每页数量</td>
          </tr>
          <tr>
            <td>current_page</td>
            <td>Number</td>
            <td>1</td>
            <td>当前所在页码</td>
          </tr>
          <tr>
            <td>last_page</td>
            <td>Number</td>
            <td>999</td>
            <td>最后一页页码</td>
          </tr>
          </tbody>
        </table>
      </div>
      <h4 class="mdui-m-t-2 mdui-m-b-1">图片数据说明</h4>
      <div class="mdui-table-fluid">
        <table class="mdui-table">
          <thead>
          <tr>
            <td>参数名称</td>
            <td>类型</td>
            <td>实例值</td>
            <td>说明</td>
          </tr>
          </thead>
          <tbody>
          <tr>
            <td>id</td>
            <td>Number</td>
            <td>1</td>
            <td>图片ID</td>
          </tr>
          <tr>
            <td>strategy</td>
            <td>String</td>
            <td>oss</td>
            <td>储存策略, (cos:腾讯云, kodo:七牛云, local:本地, oss:阿里云oss, remote:远程储存, uss:又拍云)</td>
          </tr>
          <tr>
            <td>path</td>
            <td>String</td>
            <td>2019/10/31</td>
            <td>图片所在路径</td>
          </tr>
          <tr>
            <td>alias_name</td>
            <td>String</td>
            <td>test</td>
            <td>图片别名</td>
          </tr>
          <tr>
            <td>name</td>
            <td>String</td>
            <td>929616303ca92.jpg</td>
            <td>图片名称</td>
          </tr>
          <tr>
            <td>pathname</td>
            <td>String</td>
            <td>2019/10/31/929616303ca92.jpg</td>
            <td>图片路径+名称</td>
          </tr>
          <tr>
            <td>size</td>
            <td>String</td>
            <td>30405.00</td>
            <td>图片大小(字节: b)</td>
          </tr>
          <tr>
            <td>mime</td>
            <td>String</td>
            <td>image/jpeg</td>
            <td>图片 mime 类型</td>
          </tr>
          <tr>
            <td>sha1</td>
            <td>String</td>
            <td>0143f7904f12e2a76ff2935f21a771b8adadf961</td>
            <td>图片 sha1 值</td>
          </tr>
          <tr>
            <td>md5</td>
            <td>String</td>
            <td>e630c1d832f1701b0afe09cfe86a7f2b</td>
            <td>图片 md5 值</td>
          </tr>
          <tr>
            <td>ip</td>
            <td>String</td>
            <td>192.168.0.1</td>
            <td>上传者 IP</td>
          </tr>
          <tr>
            <td>suspicious</td>
            <td>Number</td>
            <td>0</td>
            <td>是否是可疑图片, (0:否, 1:是)</td>
          </tr>
          <tr>
            <td>upload_time</td>
            <td>Number</td>
            <td>1572491936</td>
            <td>图片上传时间</td>
          </tr>
          <tr>
            <td>upload_date</td>
            <td>String</td>
            <td>2019-10-31 11:18:56</td>
            <td>图片上传日期</td>
          </tr>
          <tr>
            <td>url</td>
            <td>String</td>
            <td>http://domain.com/2019/10/31/929616303ca92.jpg</td>
            <td>图片链接</td>
          </tr>
          </tbody>
        </table>
      </div>
    </div>

    <div class="mdui-m-b-2">
      <h2>4. 获取单张图片</h2>
      <div class="mdui-row">
        <div class="mdui-col-md-6">
          <div class="mdui-table-fluid mdui-m-t-1">
            <table class="mdui-table">
              <thead>
              <tr>
                <td>功能</td>
                <td>接口</td>
              </tr>
              </thead>
              <tbody>
              <tr>
                <td>请求方式</td>
                <td>POST</td>
              </tr>
              <tr>
                <td>URL</td>
                <td>{$domain}/api/image</td>
              </tr>
              </tbody>
            </table>
          </div>
        </div>
      </div>
      <h4 class="mdui-m-t-2 mdui-m-b-1">请求参数</h4>
      <div class="mdui-table-fluid">
        <table class="mdui-table">
          <thead>
          <tr>
            <td>参数名称</td>
            <td>类型</td>
            <td>是否必须</td>
            <td>说明</td>
          </tr>
          </thead>
          <tbody>
          <tr>
            <td>id</td>
            <td>String</td>
            <td>是</td>
            <td>图片ID</td>
          </tr>
          </tbody>
        </table>
      </div>
      <h4 class="mdui-m-t-2 mdui-m-b-1">返回数据(data)与第三条相同</h4>
    </div>

    <div class="mdui-m-b-2">
      <h2>5. 删除图片</h2>
      <div class="mdui-row">
        <div class="mdui-col-md-6">
          <div class="mdui-table-fluid mdui-m-t-1">
            <table class="mdui-table">
              <thead>
              <tr>
                <td>功能</td>
                <td>接口</td>
              </tr>
              </thead>
              <tbody>
              <tr>
                <td>请求方式</td>
                <td>POST</td>
              </tr>
              <tr>
                <td>URL</td>
                <td>{$domain}/api/delete</td>
              </tr>
              </tbody>
            </table>
          </div>
        </div>
      </div>
      <h4 class="mdui-m-t-2 mdui-m-b-1">请求参数</h4>
      <div class="mdui-table-fluid">
        <table class="mdui-table">
          <thead>
          <tr>
            <td>参数名称</td>
            <td>类型</td>
            <td>是否必须</td>
            <td>说明</td>
          </tr>
          </thead>
          <tbody>
          <tr>
            <td>id</td>
            <td>String</td>
            <td>是</td>
            <td>图片ID, 删除多个使用逗号分隔</td>
          </tr>
          </tbody>
        </table>
      </div>
    </div>
  </main>
</div>
{/block}
